package org.esk.dablog.web.forms.ride;

import org.springframework.web.servlet.mvc.SimpleFormController;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;
import org.springframework.web.multipart.support.DefaultMultipartHttpServletRequest;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.validation.BindException;
import org.esk.dablog.service.EntryManager;
import org.esk.dablog.model.Entry;
import org.esk.dablog.model.Picture;
import org.esk.dablog.model.entries.Ride;
import org.esk.dablog.web.util.RequestUtils;
import org.esk.dablog.web.functions.EntryFunctions;
import org.esk.dablog.web.forms.EditEntryForm;
import org.esk.dablog.web.elements.CalendarBean;
import org.esk.dablog.exceptions.BusinessException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Iterator;
import java.util.Calendar;
import java.util.Date;

/**
 * This class extends EditEntry and provides ride-specific functions
 * User: jc
 * Date: 22.11.2006
 * Time: 12:32:34
 * $Id:$
 */
public class EditRideForm extends EditEntryForm {
    protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception {
        ModelAndView show = super.showForm(request, response, errors);
        Calendar c = Calendar.getInstance();

        Date d = RequestUtils.toDateParameter(request);
        if (d != null) {
            c.setTime(d);
        }
        CalendarBean bean = new CalendarBean();
        bean.setLocale(request.getLocale());
        bean.setShowMonths(true);
        bean.setCurrentDate(c);
        bean.setDayHref(request.getContextPath() + "/addride.form");
        show.addObject("calendar", bean);
        show.addObject("date", d);
        return show;
    }

}

